package com.hsq.ndmall.wx.controller;

import cn.hutool.core.map.MapUtil;
import com.hsq.ndmall.common.utils.R;
import com.hsq.ndmall.wx.feign.mms.MmsFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 黄四清
 * @version 1.0.0
 * @ClassName TopicController.java
 * @Description TODO 专题接口
 * @createTime 2021年08月25日 16:21:00
 */
@RestController
@RequestMapping("wx/topic")
public class TopicController {
    @Autowired
    MmsFeign mmsFeign;

    @GetMapping("list")
    public R topicList(@RequestParam Integer page, @RequestParam Integer limit) {
        Map paramMap = new HashMap<String, String>();
        paramMap.put("page", page);
        paramMap.put("limit", limit);
        R topicList = mmsFeign.listTopic(paramMap);
        return R.ok().put("data", topicList.get("page"));
    }

    // 根据Id查询详情
    @GetMapping("detail")
    public R detailInfo(@RequestParam Integer id) {
        R topicInfo = mmsFeign.topicInfo(id);
        Map<String, Object> map = new HashMap<>();
        map.put("topic", topicInfo.get("topic"));
        map.put("goods", null);
        return R.ok().put("data", map);
    }

    // 查询相关专题
    @GetMapping("related")
    public R relatedList(@RequestParam Integer id) {
        Map paramMap = new HashMap<String, String>();
        paramMap.put("page", 1);
        paramMap.put("limit", 4);
        paramMap.put("related_id", id);
        R listTopicRelate = mmsFeign.listTopic(paramMap);
        return R.ok().put("data",listTopicRelate.get("page"));
    }

}
